#ifndef __APP_DEVICE_H__
#define __APP_DEVICE_H__

#include "app_buffer.h"
#include "app_pool.h"
#include "app_common.h"
#include "app_message.h"
#include "app_mqtt.h"
#include "log/log.h"
#include <pthread.h>

typedef struct{
    char *filename;
    int fd;
    Buffer *Up_Buffer;
    Buffer *Down_Buffer;
    pthread_t Read_Thread;
    int is_running;
    long long last_write_timems;
    long interval_ms;
    int (*post_read)(char *data, int len);
    int (*pre_write)(char *data, int len);
}Device_t;

/**
 * @brief 设备初始化
 * @return int 返回初始化状态,成功返回0,失败返回-1
 */
Device_t *App_Device_Init(char *filename);

/**
 * @brief 设备启动
 */
void App_Device_Start(void);

/**
 * @brief 设备关闭
 */
void App_Device_Stop(void);

#endif
